import React from 'react';
import { Link }  from 'umi';
import { Empty, Table } from 'antd';
import { Icon } from '@/pages/Recruitment/components';
import { createDictionary } from '@/dictionary';

const [, getInterviewStatusText] = createDictionary('INTERVIEW_STATUS_ENUM');

const [, getInterviewStatusTextColor] = createDictionary('INTERVIEW_STATUS_COLOR_ENUM');

const InterviewRecords = ({ formData = {}, excludeColumn = [] }) => {
    const columns = [
        {
            title: '面试轮次',
            dataIndex: 'interviewRoundName',
            key: 'interviewRoundName'
        },
        {
            title: '面试时间',
            dataIndex: 'interviewStartTime',
            key: 'interviewStartTime',
            render: text => text || '--'
        },
        {
            title: '面试结论',
            dataIndex: 'interviewStatus',
            key: 'interviewStatus',
            render: text => (
                <span style={{ color: getInterviewStatusTextColor(text) }}>{getInterviewStatusText(text)}</span>
            )
        },
        {
            title: '面试官',
            dataIndex: 'interviewerEmployeeName',
            key: 'interviewerEmployeeName'
        },
        {
            title: '负责人',
            dataIndex: 'operateEmployeeName',
            key: 'operateEmployeeName',
            render: () => formData?.principalEmployeeName
        },
        {
            title: '操作',
            key: 'controls',
            align: 'center',
            render: (text, record) => (
                <Link to={`/office/personnelManagement/recruitment/interview/detail?candidateId=${record.candidateId}`}>
                    <Icon title="查看详情" type="listfunction_viewinterview_icon_default" />
                </Link>
            )
        }
    ];

    const nextColumns = columns.filter(item => !excludeColumn.includes(item.key));

    return formData?.interviewArranges?.length ? (
        <Table columns={nextColumns} dataSource={formData?.interviewArranges} rowKey="id" pagination={false} />
    ) : (
        <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
    );
};

export default InterviewRecords;
